describe("EppUtils", function() {
    describe("stringToNumber", function() {
        it("should be able to recognize different decimal and thousand separators", function() {
            var num = EppUtils.stringToNumber('1.234,56')
            expect(num).toEqual(1234.56);

            var num2 = EppUtils.stringToNumber('1,234.56')
            expect(num2).toEqual(1234.56);
        });

        it("should be able to ignore thousand separators", function() {
            var num = EppUtils.stringToNumber('1.234.567,89')
            expect(num).toEqual(1234567.89);
        });

        it("should be able to ignore wrong separators", function() {
            var num = EppUtils.stringToNumber('1.234.567.89')
            expect(num).toEqual(1234567.89);
        });

        it("should be able to ignore currency signs", function() {
            var num = EppUtils.stringToNumber('R$ 1.234,56')
            expect(num).toEqual(1234.56);

            var num2 = EppUtils.stringToNumber('USD 1,234.56')
            expect(num2).toEqual(1234.56);
        });

        it("should be able to ignore other characters", function() {
            var num = EppUtils.stringToNumber('"""1.234,56"""')
            expect(num).toEqual(1234.56);

            var num2 = EppUtils.stringToNumber('#@W1,234.56CF&*Y')
            expect(num2).toEqual(1234.56);
        });

        it("should return NaN on undefined, null or not a number", function() {
            expect(EppUtils.stringToNumber(undefined)).toEqual(NaN);
            expect(EppUtils.stringToNumber(null)).toEqual(NaN);
            expect(EppUtils.stringToNumber('')).toEqual(NaN);
            expect(EppUtils.stringToNumber('naosounumero')).toEqual(NaN);
        });

        it("should preserve numbers", function() {
            expect(EppUtils.stringToNumber(123.45)).toEqual(123.45);
        });
    });

    describe("formatNumber", function() {
        it("should format currency", function() {
            expect(EppUtils.formatNumber(123.1234)).toEqual('123.12');
            expect(EppUtils.formatNumber(123456.1234)).toEqual('123456.12');
            expect(EppUtils.formatNumber(123.1234, 3)).toEqual('123.123');
            expect(EppUtils.formatNumber(123.1234, 6)).toEqual('123.123400');
            expect(EppUtils.formatNumber(123.1234, 3, 'R$ ')).toEqual('R$ 123.123');
            expect(EppUtils.formatNumber(123.1234, 3, 'R$ ', true)).toEqual('R$ 123,123');
        });
    });

});
